#include <iostream>
#include <string>
#include "Software.h"

using namespace std;


Software::Software(string ID, string title, string language, string version, string Brand, int stock, int price):Product(ID, Brand, stock, price){
	this->title = title;
	this->language = language;
	this->version = version;
}

map <int, string> Software::getHeader(){
	map <int, string> result;
	result[0] = "ID";
	result[1] = "Title";
	result[2] = "Language";
	result[3] = "Version";
	result[4] = "Brand";
	result[5] = "Stock";
	result[6] = "Price";
	return result;
}

map <int, int> Software::getHeaderLength(){
	map <int, int> result;
	result[0] = 10;
	result[1] = 20;
	result[2] = 10;
	result[3] = 9;
	result[4] = 15;
	result[5] = 7;
	result[6] = 7;
	return result;
}

map <int, string> Software::getAllData(){
	map <int, string> result;
	result[0] = id;
	result[1] = title;
	result[2] = language;
	result[3] = version;
	result[4] = brand;
	result[5] = int2str(stock);
	result[6] = int2str(price);
	return result;
}

bool Software::isLarger(int compareFactor, Product *product2){
	Software *software = dynamic_cast < Software * >(product2);

	//remark: if(hardDisk != 0) is insert for safety reason. It won't be false under proper communication between classes

	switch (compareFactor){
	case 0:
		return !product2->Product::isLarger(compareFactor, this);
	case 1: //compare by title
		if(software != 0)
			return this->title.compare(software->title) > 0;
	case 2: //compare by language
		if(software != 0)
			return this->language.compare(software->language) > 0;
	case 3: //compare by version
		if(software != 0)
			return this->version.compare(software->version) > 0;
	default: //call parent comparason
		return !product2->Product::isLarger(compareFactor-3, this);
	}
}